package com.company.user.vo;

import com.company.common.util.BCryptUtil;
import com.company.user.entity.UserEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.poi.ss.usermodel.Row;

import java.util.Date;

@ApiModel("员工excel的数据")
public class ExcelStaffListVo {

    @ApiModelProperty("第几行")
    private Integer row;

    @ApiModelProperty("用户姓名--例如张三")
    private String userName;

    @ApiModelProperty("登录用户名")
    private String loginName;

    @ApiModelProperty("登陆密码")
    private String password;

    @ApiModelProperty("所属部门")
    private String departmentId;

    @ApiModelProperty("职位")
    private String positionId;

    @ApiModelProperty("手机号码")
    private String phoneNumber;

    @ApiModelProperty("用户描述信息")
    private String description;

    @ApiModelProperty("备注")
    private String remark;

    public Integer getRow() {
        return row;
    }

    public void setRow(Integer row) {
        this.row = row;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getLoginName() {
        return loginName;
    }

    public void setLoginName(String loginName) {
        this.loginName = loginName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getPositionId() {
        return positionId;
    }

    public void setPositionId(String positionId) {
        this.positionId = positionId;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public ExcelStaffListVo copyTo(Row row) {
        ExcelStaffListVo excelStaffListVo = new ExcelStaffListVo();
        excelStaffListVo.setRow(row.getRowNum());
        if (row.getCell(0) != null && !"".equals(row.getCell(0).toString())) {
            excelStaffListVo.setUserName(row.getCell(0).toString());
        }
        if (row.getCell(1) != null && !"".equals(row.getCell(1).toString())) {
            excelStaffListVo.setLoginName(row.getCell(1).toString());
        }
        if (row.getCell(2) != null && !"".equals(row.getCell(2).toString())) {
            excelStaffListVo.setPassword(BCryptUtil.hashpw(row.getCell(2).toString()));
        }
        if (row.getCell(3) != null && !"".equals(row.getCell(3).toString())) {
            excelStaffListVo.setDepartmentId(row.getCell(3).toString());
        }
        if (row.getCell(4) != null && !"".equals(row.getCell(4).toString())) {
            excelStaffListVo.setPositionId(row.getCell(4).toString());
        }
        if (row.getCell(5) != null && !"".equals(row.getCell(5).toString())) {
            excelStaffListVo.setPhoneNumber(row.getCell(5).toString());
        }
        if (row.getCell(6) != null && !"".equals(row.getCell(6).toString())) {
            excelStaffListVo.setDescription(row.getCell(6).toString());
        }
        if (row.getCell(7) != null && !"".equals(row.getCell(7).toString())) {
            excelStaffListVo.setRemark(row.getCell(7).toString());
        }
        return excelStaffListVo;
    }

    @Override
    public String toString() {
        return "解析出来的数据是----> {" + "row=" + row + ", userName='" + userName + ", loginName='" + loginName + '\'' +
                ", password='" + password +
                ", departmentId='" + departmentId +
                ", positionId='" + positionId +
                ", phoneNumber='" + phoneNumber +
                ", description='" + description +
                ", remark='" + remark +
                '}';
    }

    public void copyTo(UserEntity user){
        user.setUserName(this.userName);
        user.setLoginName(this.loginName);
        user.setPassword(this.password);
        user.setDepartmentId(this.departmentId);
        user.setPositionId(this.positionId);
        user.setPhoneNumber(this.phoneNumber);
        user.setDescription(this.description);
        user.setRemark(this.remark);
    }
}
